@extends('layouts.admin')
@section('content')
      <section id="main-content">
          <section class="wrapper">
              <!-- page start-->
              <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                      
                          <header class="panel-heading">
                              角色列表
                          </header>
                          <div class="panel-body right"  align="right">
                              <div class="form-group " align="" >
                                    <a class="btn btn-primary settle" name="to" data-href="" href="{{ route('admin.access.roles.create') }}">新增</a> 
                                    <!-- <a  class="btn btn-danger settleAll" name="to" data-href="">删除</a> -->
                                  </div>
                          </div>
                          <table class="table table-striped table-advance table-hover">

                              <thead>
                              <tr>
                                   <th>
                                        <span class="ckbox ckbox-primary">
                                            <!-- <input type="checkbox" id="selectall"/> -->
                                            <label for="selectall"></label>
                                        </span>
                                    </th>
                                    <th>标识</th>
                                    <th>角色名</th>
                                    <th>级别</th>
                                    <th>说明</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                  <!-- <th><i class="icon-bullhorn"></i> Company</th>
                                  <th class="hidden-phone"><i class="icon-question-sign"></i> Descrition</th>
                                  <th><i class="icon-bookmark"></i> Profit</th>
                                  <th><i class=" icon-edit"></i> Status</th>
                                  <th></th> -->
                              </tr>
                              </thead>
                              <tbody>
                              <tr>
                               @foreach($roles as $role)
                                    <tr>
                                        <td>
                                            <div class="ckbox ckbox-default">
                                                <!-- <input type="checkbox" name="id" id="id-{{ $role->id }}"
                                                       value="{{ $role->id }}" class="selectall-item"/> -->
                                                <label for="id-{{ $role->id }}"></label>
                                            </div>
                                        </td>
                                        <td>{{ $role->slug }}</td>
                                        <td>{{ $role->name }}</td>
                                        <td>{{ $role->level }}</td>
                                        <td>{{ $role->description }}</td>
                                        <td>{{ $role->created_at }}</td>
                                        <td>
                                            <a href="{{ route('admin.access.roles.edit',['id'=>$role->id]) }}"
                                               class="btn btn-primary btn-xs"><i class="icon-pencil"></i> </a>
                                            <a href="{{ route('admin.access.roles.permissions',['id'=>$role->id]) }}"
                                            class="btn btn-info btn-xs role-permissions"><i class="icon-wrench"></i> </a>
                                            <a class="btn btn-danger btn-xs role-delete"
                                               data-href="{{ route('admin.access.roles.destroy',['id'=>$role->id]) }}">
                                                <i class="icon-trash"></i> </a>
                                        </td>
                                    </tr>
                                @endforeach
                              </tr>
                             <!--  <tr>
                                  <td><a href="#">Vector Ltd</a></td>
                                  <td class="hidden-phone">Lorem Ipsum dorolo imit</td>
                                  <td>12120.00$ </td>
                                  <td><span class="label label-info label-mini">Due</span></td>
                                  <td>
                                      <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                      <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                      <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                  </td>
                              </tr> -->
                        
                              </tbody>
                          </table>
                           {!! $roles->render() !!}
                           </div>
                           </div>
                      </section>
                  </div>
              </div>
              <!-- page end-->
          </section>
      </section>
@endsection
@section('javascript')
    @parent
   <script src="{{ asset('admin/rbacjs/toggles.min.js') }}"></script>
  <script src="{{ asset('admin/js/ajax.js') }}"></script>
    <script type="text/javascript">
        $(".role-delete").click(function () {
            Rbac.ajax.delete({
                type:'delete',
                data:{"_token" : "{{ csrf_token() }}" },
                confirmTitle: '确定删除角色?',
                href: $(this).data('href'),
                successTitle: '角色删除成功',
                errorFnc:function(data){
                      swal('删除失败！', '', 'error');
                }
            });
        });

        $(".deleteall").click(function () {
            Rbac.ajax.deleteAll({
                confirmTitle: '确定删除选中的角色?',
                href: $(this).data('href'),
                successTitle: '角色删除成功'
            });
        });
    </script>

@endsection


